function Polygon(){
	this.id = null;
	this.parent = null;
	this.points = [];
	this.points3D = [];
	this.color = null;
	this.avg_z = null;
	this.showAsSelected = false;
	this.renderMethod = null;
	
	this.visible = false;
	this.curveData = [];
	
	this.createCurveControlPoints = function(ctx){
		if(this.visible == false){
			return;
		}
		
		//ctx.fillStyle = polygonObj.color;
		this.curveData = [];
		for(var i=0; i < this.points3D.length; i++){
			if( i+1 < this.points3D.length)
				this.addToCurve(this.points3D[i], this.points3D[i+1]);
			else
				this.addToCurve(this.points3D[3], this.points3D[0]);
		}
		var temp = this.curveData.shift();
		this.curveData.push(temp);
		
		ctx.fillStyle = this.color;
		ctx.beginPath();
		
		ctx.fillStyle = this.color;
		
	    ctx.moveTo(this.curveData[0].x, this.curveData[0].y);
	    
	    ctx.quadraticCurveTo(this.curveData[1].x, this.curveData[1].y, this.curveData[2].x, this.curveData[2].y);
	    ctx.lineTo(this.curveData[3].x, this.curveData[3].y);
	    
	    ctx.quadraticCurveTo(this.curveData[4].x, this.curveData[4].y, this.curveData[5].x, this.curveData[5].y);
	    ctx.lineTo(this.curveData[6].x, this.curveData[6].y);
	    
	    ctx.quadraticCurveTo(this.curveData[7].x, this.curveData[7].y, this.curveData[8].x, this.curveData[8].y);
	    ctx.lineTo(this.curveData[9].x, this.curveData[9].y);
	    
	    ctx.quadraticCurveTo(this.curveData[10].x, this.curveData[10].y, this.curveData[11].x, this.curveData[11].y);
	    ctx.lineTo(this.curveData[0].x, this.curveData[0].y);
	    
	    ctx.closePath();
	    ctx.fill();
	    
	    ctx.strokeStyle = '#CCCCCC';
	    ctx.stroke();
		
	};
	
	
	this.addToCurve = function(point1,point2){
		var delta_x = point2.x - point1.x;
		var delta_y = point2.y - point1.y;
		
		var cc1_x = point1.x + delta_x * 0.3;
		var cc1_y = point1.y + delta_y * 0.3;
		
		
		var cc2_x = point1.x + delta_x * 0.7;
		var cc2_y = point1.y + delta_y * 0.7;
		
		this.curveData.push({x:cc1_x,    y:cc1_y});
		this.curveData.push({x:cc2_x,    y:cc2_y});
		this.curveData.push({x:point2.x, y:point2.y});
	};
}